package com.zz.itext7;

import com.itextpdf.forms.PdfAcroForm;
import com.itextpdf.forms.fields.PdfButtonFormField;
import com.itextpdf.forms.fields.PdfFormField;
import com.itextpdf.forms.fields.PdfTextFormField;
import com.itextpdf.io.font.PdfEncodings;
import com.itextpdf.kernel.font.PdfFont;
import com.itextpdf.kernel.font.PdfFontFactory;
import com.itextpdf.kernel.geom.Rectangle;
import com.itextpdf.kernel.pdf.PdfDocument;
import com.itextpdf.kernel.pdf.PdfReader;
import com.itextpdf.kernel.pdf.PdfWriter;
import com.itextpdf.layout.Document;
import com.itextpdf.layout.element.List;
import com.itextpdf.layout.element.ListItem;
import com.itextpdf.layout.element.Paragraph;

public class demo2 {
    public static void main(String[] args) throws Exception {
        PdfDocument pdf = new PdfDocument(new PdfWriter("D:\\测试pdf\\day5_1.pdf"));
        Document doc = new Document(pdf);
        PdfFont font = PdfFontFactory.createFont("C:/Windows/Fonts/simyou.ttf", PdfEncodings.IDENTITY_H,true);
        List list = new List().setSymbolIndent(12).setListSymbol("\u2022").setFont(font).setFontSize(15);
        list.add(new ListItem("《游山西村》  陆游"))
                .add(new ListItem("莫笑农家腊酒浑，丰年留客足鸡豚。"))
                .add(new ListItem("山重水复疑无路，柳暗花明又一村。"))
                .add(new ListItem("箫鼓追随春社近，衣冠简朴古风存。"))
                .add(new ListItem("从今若许闲乘月，拄杖无时夜叩门。"));
        doc.add(list);
        //获取当前pdf实例第二个参数值是布尔值，指示如果没有表单是否创建新的表单
        PdfAcroForm from = PdfAcroForm.getAcroForm(doc.getPdfDocument(),true);
        //文本域

        Paragraph p = new Paragraph("姓名：");
        PdfTextFormField field = PdfTextFormField.createText(doc.getPdfDocument(),new Rectangle(99,650,425,15),"name","");
        PdfButtonFormField button = PdfFormField.createRadioGroup(doc.getPdfDocument(),"language","");

        from.addField(field);
        pdf.close();
    }
}
